﻿
$(function () {
    var yaodianming = getQuery('yaodianming');
    if (yaodianming == undefined || yaodianming == null || yaodianming == '')
        yaodianming = "龙山县";

	// 百度地图API功能
    var lng;
    var lat;
    var map = new BMap.Map("allmap");        

    //map.centerAndZoom(new BMap.Point(109.450, 29.363), 13);
    //map.enableScrollWheelZoom(true);
    var options = {
        onSearchComplete: function (results) {
            // 判断状态是否正确
            if (local.getStatus() == BMAP_STATUS_SUCCESS) {
                //var s = [];
                //for (var i = 0; i < results.getCurrentNumPois(); i++) {
                //    s.push(results.getPoi(i).title + ", " + results.getPoi(i).address);
                //}
                //document.getElementById("r-result").innerHTML = s.join("<br/>");
                lng = results.getPoi(0).point.lng;
                lat = results.getPoi(0).point.lat;
            }
            //map.panTo(new BMap.Point(lng, lat));
            setTimeout(function () {
                map.centerAndZoom(new BMap.Point(lng, lat), 17); 
            }, 100);
        },
        renderOptions: { map: map }
    };

    var local = new BMap.LocalSearch(map, options);
    local.search(yaodianming);
});

